<template>
	<view class="content">

		<view class="btn" @click="gotoLoginview()" v-if="showData == 0">
			登陆
		</view>

		<view class="btn" @click="gotoRegView()" v-if="showData == 1">
			注册
		</view>

	</view>
</template>

<script setup>
	import {
		getIsUser
	} from '@/api/mine_api.js'
	import {
		ref
	} from 'vue'

	import {
		onLoad
	} from '@dcloudio/uni-app'

	const showData = ref(0)


	// 跳转注册
	const gotoRegView = () => {
		uni.navigateTo({
			url: `/views/changuanruzhu/loginview/loginview`
		})
	}

	// 跳转登陆界面
	const gotoLoginview = () => {
		uni.navigateTo({
			url: `/views/changuanruzhu/webview/webview`
		})
	}

	// 跳转实名认证界面

	// 跳转
	const _getIsUser = (id) => {
		getIsUser(id).then((res)=>{
			console.log(res);
			
			if (res.result == '有用户') {
				showData.value = 0
			} else if (res.result == '无用户') {
				showData.value = 1
			} else {
				
			}
		})
	}

	onLoad(() => {
		uni.getStorage({
			key: 'openid',
			success: function(res) {
				console.log(res.data.openid);
				_getIsUser(res.data.openid)
			}
		})
	})
</script>

<style scoped lang="scss">
	.content {
		display: flex;
		justify-content: space-evenly;
		flex-direction: column;
		padding: 0 40px;
		height: 100vh;

		.btn {
			padding: 20px 0;
			text-align: center;
			background-color: skyblue;
			border: 1px solid white;
			border-radius: 40px;
			color: white;
		}
	}
</style>